I am having trouble getting values populated in my form... Here is what I
got so far:
//The values that need to be selected
$result_ip=pg_query($dbconn,$test_query);
Re: HTML FORMS selected question
am 04.12.2006 00:08:09 von Chris
Mag Gam wrote:
> I am having trouble getting values populated in my form... Here is what
> I got so far:
>
> //The values that need to be selected
> $result_ip=pg_query($dbconn,$test_query);
>
>
Re: HTML FORMS selected question
am 04.12.2006 00:17:37 von Chris
Please CC the list so they can suggest things and learn as well.
Mag Gam wrote:
> Hi Chris:
>
> $rows is an array of all the values
> $options is an array of all the values selected
I meant can you give an example of what they both contain?
I know what they *should* contain - what do they *actually* contain?
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
Re: HTML FORMS selected question
am 04.12.2006 00:23:45 von Randy Moller
Maybe it's just a typo, but your pg_query is returning into the var
$result_ip, while your fetch is referencing var $result (without _ip).
Maybe that's just a typo for your question, but if not, that is at least one
error.
Also, it would be helpful to know what error you're getting....
Randy Moller
-----Original Message-----
From: pgsql-php-owner@postgresql.org [mailto:pgsql-php-owner@postgresql.org]
On Behalf Of Chris
Sent: Sunday, December 03, 2006 4:08 PM
To: Mag Gam
Cc: pgsql-php@postgresql.org
Subject: Re: [PHP] HTML FORMS selected question
Mag Gam wrote:
> I am having trouble getting values populated in my form... Here is what
> I got so far:
>
> //The values that need to be selected
> $result_ip=pg_query($dbconn,$test_query);
>
>
$rows contain ip addresses (postgresql inet) type (example: 192.168.0.1)
$options contain ip addresses (postgresql inet0 type (example: 127.0.0.1)
(keep in mind) they are both arrays. $rows contact all ips, and $options
contact the ip addresses that were selected
Randy:
I am not sure what you mean. The variables look right. I am getting no
errors! Just the logic is messed up.
HTH
On 12/3/06, Randy Moller wrote:
>
> Maybe it's just a typo, but your pg_query is returning into the var
> $result_ip, while your fetch is referencing var $result (without _ip).
> Maybe that's just a typo for your question, but if not, that is at least
> one
> error.
>
> Also, it would be helpful to know what error you're getting....
>
> Randy Moller
>
> -----Original Message-----
> From: pgsql-php-owner@postgresql.org [mailto:
> pgsql-php-owner@postgresql.org]
> On Behalf Of Chris
> Sent: Sunday, December 03, 2006 4:08 PM
> To: Mag Gam
> Cc: pgsql-php@postgresql.org
> Subject: Re: [PHP] HTML FORMS selected question
>
> Mag Gam wrote:
> > I am having trouble getting values populated in my form... Here is what
> > I got so far:
> >
> > //The values that need to be selected
> > $result_ip=pg_query($dbconn,$test_query);
> >
> >
Re: HTML FORMS selected question
am 04.12.2006 00:48:05 von Chris
Mag Gam wrote:
> Randy + Chris:
>
> Thx for the quick replies!
>
> Chris:
>
> $rows contain ip addresses (postgresql inet) type (example: 192.168.0.1
> )
> $options contain ip addresses (postgresql inet0 type (example: 127.0.0.1
> )
> (keep in mind) they are both arrays. $rows contact all ips, and $options
> contact the ip addresses that were selected
>
> Randy:
> I am not sure what you mean. The variables look right. I am getting no
> errors! Just the logic is messed up.
I think Randy's right.
At the top you have:
//The values that need to be selected
$result_ip=pg_query($dbconn,$test_query);
^^^^^^^^^
but you are doing this:
while ($row = pg_fetch_array($result)) {
$result_ip at the top, $result in the second bit.
If you don't see errors, turn up error reporting & display errors:
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
Sorry, I may of forgetten to give you this:
$result = pg_query($dbconn, "select id,address from ip");
This is right before the:
$options=pg_fetch_array($result_ip);
so, my $results is really all the ip addresses ($rows after I perform the
pg_fetch_array).
I will add the var_dump to see it (never done it before, I will do some
googling :) )
On 12/3/06, Chris wrote:
>
> Mag Gam wrote:
> > Randy + Chris:
> >
> > Thx for the quick replies!
> >
> > Chris:
> >
> > $rows contain ip addresses (postgresql inet) type (example: 192.168.0.1
> > )
> > $options contain ip addresses (postgresql inet0 type (example: 127.0.0.1
> > )
> > (keep in mind) they are both arrays. $rows contact all ips, and $options
> > contact the ip addresses that were selected
> >
> > Randy:
> > I am not sure what you mean. The variables look right. I am getting no
> > errors! Just the logic is messed up.
>
> I think Randy's right.
>
> At the top you have:
>
> //The values that need to be selected
> $result_ip=pg_query($dbconn,$test_query);
> ^^^^^^^^^
> but you are doing this:
>
> while ($row = pg_fetch_array($result)) {
>
>
> $result_ip at the top, $result in the second bit.
>
>
> If you don't see errors, turn up error reporting & display errors:
>
> error_reporting(E_ALL);
> ini_set('display_errors', true);
>
>
> Also that's not what I meant. I meant add a var_dump or print_r at each
> stage to see what you are *really* getting from the code.
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
Mag Gam wrote: > Randy + Chris: > > Thx for the quick replies!
> > Chris: > > $rows contain ip addresses (postgresql inet) type (example: >) > $options contain ip addresses (postgresql inet0 type (example:
>) > (keep in mind) they are both arrays. $rows contact all ips, and $options > contact the ip addresses that were selected
> > Randy: > I am not sure what you mean. The variables look right. I am getting no > errors! Just the logic is messed up.
I think Randy's right.
At the top you have:
//The values that need to be selected
$result_ip=pg_query($dbconn,$test_query); ^^^^^^^^^ but you are doing this:
while ($row = pg_fetch_array($result)) {
$result_ip at the top, $result in the second bit.
If you don't see errors, turn up error reporting & display errors:
1. first, you are querying a database (I assume a postgres db) like
this:
=20
$result =3D pg_query($dbconn, =93select…”) , so,
=20
$result now is a =93resource reference=94 which contains the =
=93result=94 of the
query. However, now you need to tell php to return the contents of that
resource to you (you can return in either an indexed, associative, or =
object
array). So, to get your =93array=94, you now use $result like this:
=20
$myArray =3D pg_fetch_array($result);
=20
Now $myArray is the actual =93row/s=94 you returned in $result.
=20
Does that make sense?
=20
So, when you first query, $result (or $result_ip) =3D pg_query(conn, =
sql), you
need to be consistent with your variables. Either use $result_ip, or
$result, but not both=85.My guess is that=92s your problem.
=20
Hope that helps!
Randy
_____ =20
From: pgsql-php-owner@postgresql.org =
[mailto:pgsql-php-owner@postgresql.org]
On Behalf Of Mag Gam
Sent: Sunday, December 03, 2006 5:01 PM
To: Chris
Cc: Randy Moller; pgsql-php@postgresql.org
Subject: Re: [PHP] HTML FORMS selected question
=20
Chris + Randy:
Sorry, I may of forgetten to give you this:
$result =3D pg_query($dbconn, "select id,address from ip");
This is right before the:
$options=3Dpg_fetch_array($result_ip);
so, my $results is really all the ip addresses ($rows after I perform =
the
pg_fetch_array).=20
I will add the var_dump to see it (never done it before, I will do some
googling :) )
On 12/3/06, Chris
dmagick@gmail.com>
wrote:
Mag Gam wrote:
> Randy + Chris:
>
> Thx for the quick replies!=20
>
> Chris:
>
> $rows contain ip addresses (postgresql inet) type (example: HYPERLINK
"http://192.168.0.1"192.168.0.1
> )
> $options contain ip addresses (postgresql inet0 type (example: =
HYPERLINK
"http://127.0.0.1"127.0.0.1
> )
> (keep in mind) they are both arrays. $rows contact all ips, and =
$options
> contact the ip addresses that were selected=20
>
> Randy:
> I am not sure what you mean. The variables look right. I am getting no
> errors! Just the logic is messed up.
I think Randy's right.
At the top you have:
//The values that need to be selected=20
$result_ip=3Dpg_query($dbconn,$test_query);
^^^^^^^^^
but you are doing this:
while ($row =3D pg_fetch_array($result)) {
$result_ip at the top, $result in the second bit.
If you don't see errors, turn up error reporting & display errors:=20
lfo1'>
color=3Dnavy face=3DArial>
style=3D'font-size:10.0pt;font-family:Arial'>first,
you are querying a database (I assume a postgres db) like =
this:
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>$result now is a “resource =
reference”
which contains the “result” of the query. However, now you =
need to tell php to
return the contents of that resource to you (you can return in either an
indexed, associative, or object array). So, to get your =
“array”, you now use
$result like this:
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>So, when you first query, $result =
(or
$result_ip) =3D pg_query(conn, sql), you need to be consistent with your
variables. Either use $result_ip, or $result, but not both….My =
guess is that’s
your problem.
Mag Gam wrote:
> Chris + Randy:
>
> Sorry, I may of forgetten to give you this:
> $result = pg_query($dbconn, "select id,address from ip");
>
> This is right before the:
> $options=pg_fetch_array($result_ip);
>
> so, my $results is really all the ip addresses ($rows after I perform
> the pg_fetch_array).
>
> I will add the var_dump to see it (never done it before, I will do some
> googling :) )
After your query add it:
$result = pg_query(....)
var_dump($result);
if that's not a "resource" then you have a problem with your query. Use
pg_last_error to work it out.
Inside your loop, add it:
while ($row = pg_fetch_array($result)) {
var_dump($row);
}
----- Original Message ----=0AFrom: Mag Gam =0ATo: pgsq=
l-php@postgresql.org=0ASent: Sunday, December 3, 2006 2:42:36 PM=0ASubject:=
[PHP] HTML FORMS selected question
I am having trouble getting values=
populated in my form... Here is what I got so far:
//The values that =
need to be selected=0A$result_ip=3Dpg_query($dbconn,$test_query);
ECT NAME=3D"ip[]" SIZE=3D10 MULTIPLE>
values.=0Awhile($rows=3Dpg_fetch_array($result)){=0Aforeach ($options as $=
index =3D> $option) {=0A if ($rows[1]==$option)=0A {=0Aecho "
ioN VALUE=3D\"$rows[0]\" selected=3D\"selected\">$rows[1] \n"; =0A=
=0Abreak;=0A }=0Aelse=0A{=0A echo " \n"; =0A break;=0A}=0A}=0A}
What am I doing wrong?=
TIA!
---------------------------
Mag, i'm not sure what is =
wrong with the specific code, however, i'll make a suggestion that i think =
will help you more than just resolving this issue.
i recommend you loo=
k into learning a forms class. the code will be much cleaner and the thoug=
ht process is much more obvious. the icing on the cake is the increased fu=
nctionality you will get "out of the box" because some smart person coded i=
t right into their forms class. for example, i get client side and server =
side error checking and error message reporting. i also get to have my for=
m give focus to the first element via javascript. there is some ajaxy stuf=
f i haven't learned yet, but it is available.
i use Manuel Lemos' free=
forms generation and validation class which can be found on phpclasses.org=
.. iirc, the license is such that it can be included in proprietary commerc=
ial applications. there are others, too. i believe pear has one, along wi=
th some other functionality.
i'm very glad i went with a forms class i=
nstead of "htmling" it all. i think you will be, too.
Manuel has a ya=
hoo mailing list that is very helpful and reasonably active. Most question=
s are answered within a day or so.
good luck.
=0A___=
____________________________________________________________ _______________=
______=0ADo you Yahoo!?=0AEveryone is raving about the all-new Yahoo! Mail =
beta.=0Ahttp://new.mail.yahoo.com
--0-436170247-1165255151=:11557
Content-Type: text/html; charset=ascii
Content-Transfer-Encoding: quoted-printable
ad>
font-size:10pt">
erif; font-size: 10pt;">----- Original Message ----
amily: times new roman,new york,times,serif; font-size: 12pt;">From: Mag Ga=
m <magawake@gmail.com> To: pgsql-php@postgresql.org Sent: Sunda=
y, December 3, 2006 2:42:36 PM Subject: [PHP] HTML FORMS selected questi=
on
I am having trouble getting values populated in my form... Here i=
s what I got so far:
//The values that need to be selected $resul=
t_ip=3Dpg_query($dbconn,$test_query);
<SELECT N=
AME=3D"ip[]" SIZE=3D10 MULTIPLE>=0A <?php //This will show ALL=
values. while($rows=3Dpg_fetch_array($result)){ foreach ($options as=
$index =3D> $option) { if ($rows[1]==$option)=
Mag, i'm not sure what is wrong with=
the specific code, however, i'll make a suggestion that i think will help =
you more than just resolving this issue.
i recommend you look into l=
earning a forms class. the code will be much cleaner and the thought =
process is much more obvious. the icing on the cake is the increased =
functionality you will get "out of the box" because some smart person coded=
it right into their forms class. for example, i get client side and =
server side error checking and error message reporting. i also get to=
have my form give focus to the first element via javascript. there i=
s some ajaxy stuff i haven't learned yet, but it is
available.
i use Manuel Lemos' free forms generation and validation=
class which can be found on phpclasses.org. iirc, the license is suc=
h that it can be included in proprietary commercial applications. the=
re are others, too. i believe pear has one, along with some other fun=
ctionality.
i'm very glad i went with a forms class instead of "html=
ing" it all. i think you will be, too.
Manuel has a yahoo mail=
ing list that is very helpful and reasonably active. Most questions a=
re answered within a day or so.
good luck.
= Have a burning question? Go to
..yahoo.com/;_ylc=3DX3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMz OTY1NDUxMDMEc2Vj=
A21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx">Yahoo! Answers and get answers fr=
om real people who know.
--0-436170247-1165255151=:11557--